<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 1. 通过调用 RegExp 对象的构造函数创建
      var regexp = new RegExp(/123/)
      console.log(regexp)

      // 2. 通过字面量创建
      let rg = /123/
      // a1
      console.log(rg.test(123), rg.test('abc'))
    </script>
  </body>
</html>
